/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef GAME_GAME_DBCSTORES_H_
#define GAME_GAME_DBCSTORES_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <list>
#include <boost/unordered_map.hpp>
#include "Shared/Global_Macros.h"
#include "Shared/DBC/DBCStore.h"
#include "Game/Game/DBCStructure.h"

typedef std::list<std::uint32_t> SimpleFactionsList;
typedef boost::unordered_map<std::uint32_t, SimpleFactionsList > FactionTeamMap;

class DBCStores
{
public:
    DBCStores(void);
    ~DBCStores(void);

    bool loadDBC(const std::string& dataPath);

    Shared::DBC::DBCStorage<ChrClassesEntry> &chrClassesStore(void) { return _chrClassesStore; }
    Shared::DBC::DBCStorage<ChrRacesEntry> &chrRacesStore(void) { return _chrRacesStore; }
    Shared::DBC::DBCStorage<CreatureFamilyEntry> &creatureFamilyStore(void) { return _creatureFamilyStore; }

    Shared::DBC::DBCStorage<FactionEntry> &factionStore(void) { return _factionStore; }
    Shared::DBC::DBCStorage<ItemRandomPropertiesEntry> &itemRandomPropertiesStore(void) { return _itemRandomPropertiesStore; }
    Shared::DBC::DBCStorage<LockEntry> &lockStore(void) { return _lockStore; }
    Shared::DBC::DBCStorage<MapEntry> &mapStore(void) { return _mapStore; }

    Shared::DBC::DBCStorage<SkillLineAbilityEntry>  &skillLineAbilityStore(void) { return _skillLineAbilityStore; }

    Shared::DBC::DBCStorage<SpellEntry> &spellStore(void) { return _spellStore; }
    SpellCategoryStore &spellCategoryStore(void) { return _spellCategoryStore; }

    static DBCStores *instance(void);
private:
    Shared::DBC::DBCStorage<ChrClassesEntry> _chrClassesStore;
    Shared::DBC::DBCStorage<ChrRacesEntry>  _chrRacesStore;
    Shared::DBC::DBCStorage<CreatureFamilyEntry> _creatureFamilyStore;
    Shared::DBC::DBCStorage<FactionEntry> _factionStore;
    FactionTeamMap _factionTeamMap;
    Shared::DBC::DBCStorage<ItemRandomPropertiesEntry> _itemRandomPropertiesStore;
    Shared::DBC::DBCStorage<LockEntry> _lockStore;
    Shared::DBC::DBCStorage<MapEntry> _mapStore;
    PetFamilySpellsStore _petFamilySpellsStore;
    Shared::DBC::DBCStorage<SkillLineAbilityEntry> _skillLineAbilityStore;
    Shared::DBC::DBCStorage<SpellEntry> _spellStore;
    SpellCategoryStore _spellCategoryStore;

    static DBCStores *_instance;
    DISALLOW_COPY_AND_ASSIGN(DBCStores);
};

#define dbcStores   (*(DBCStores::instance()))

#endif // GAME_GAME_DBCSTORES_H_
